information of the program.
Let's take a simple example. Find the source code of a program that can run, such as the following file main. C:
#include
First, compile with the following command:
Snail il @ Ubuntu :~ /Test/GPROF $ CC-O main-PG main. c
Then, run the executable file main.
Snail il @ Ubuntu :~ /Test/GPROF $./main
After running, a file gmon. out will be generated in the current directory. This is the file generated by GPROF, which stor
When writing programs, especially embedded programs, we usually need to analyze the program's performance so that the program can run faster and better to achieve real-time. If the program is large, it will be difficult to analyze it. If there is a tool that can automatically analyze the program's performance, it would be better. The following describes a Program Profiling tool in Linux-GNU profiler.
Basic usage of gprof:
1. Use the-pg option to compile and link your application
When compiling a
program compilation so that GCC can insert appropriate commands in your code. To use GPROF, you must use the-PG option. By default, this will analyze each function executed. If you want to analyze each line, you must use the-G option at the same time. GCC inserts debugging information so that GPROF can generate row reports.When the program runs, the function call and time consumption are stored in the memory. When the program exits, the information is written to the
Original article address:
Http://apps.hi.baidu.com/share/detail/5908917
GPROF IntroductionGPROF is the GNU profiler tool. Can be displayedProgramThe running "flat profile", including the number of calls to each function and the processor time consumed by each function. You can also display the "Call diagram", including the call relationship of the function, and the time consumed by each function call. You can also display the "commentedSource code", Is the program sourceCodeIndicates th
(Oracle Cluster Registry) in asm.
2 RBAL-ASM Rebalance Master Process
Coordinate rebalancing activities.
In the asm instance, the Process coordinates the rebalancing activity in the asm disk group and executes a global open (open) operation on the asm disk)
In the database instance, this process manages the asm disk group
3. ARBn-ASM Rebalance Process
Rebalance data extent within an asm Disk
The possible process is ARB0-ARB9 (ARB0, ARB1,...) and ARBA. ---> question: No ARBB? So far as ARBA?
process is ARB0-ARB9 (arb0, arb1,...) and Arba. ---> question: No arbb? So far as Arba?
4. dbwr-database writer Process
Managing ASM buffer cache
5. SMON-system monitor process
The system monitors and communicates with the cssd process.
6. ckpt-Checkpoint Process
Manage cross-instance calls in the Cluster Environment)
7. psp0-process spawner Process
After the initialization instance is started, other ASM background processes are generated.
8. gmon
.
Use the-PG option to compile hello. C. If you want to get the source code list with annotations, you need to add the-G option. Run: gcc-PG-g-o hello. c
Run the application:./Hello will generate the gmon. Out file in the current directory.
To use GPROF to analyze the gmon. Out file, you need to associate it with the application that generates it:
GPROF Hello
GPROF Introduction
GPROF is the GNU profiler tool. It can display the "flat profile" of the program running, including the number of calls to each function and the processor time consumed by each function. You can also display the "Call diagram", including the call relationship of the function, and the time consumed by each function call. You can also display the "annotated source code", which is a copy of the program source code, marking the number of executions of each line of code in the prog
: group DATA2: updated PST location: disk 0001 (PST copy 0)NOTE: group DATA2: updated PST location: disk 0002 (PST copy 1)NOTE: group DATA2: updated PST location: disk 0003 (PST copy 2)NOTE: GMON heartbeating for grp 3GMON querying group 3 at 38for pid 20, osid 7681NOTE: Assigning number (3, 0) to disk ()GMON querying group 3 at 39 for pid 20, object ID 7681NOTE: cache dismounting (clean) group 3/0x62589C78
extent within an asm DiskThe possible process is ARB0-ARB9 (ARB0, ARB1,...) and ARBA. ---> question: No ARBB? So far as ARBA?4. DBWR-Database Writer ProcessManaging asm buffer cache5. SMON-System Monitor ProcessThe system monitors and communicates with the cssd process.6. CKPT-Checkpoint ProcessManage cross-instance calls in the cluster Environment)7. PSP0-Process Spawner ProcessAfter the initialization instance is started, other asm background processes are generated.8.
effect chart: Every second of the page, the time is beating
The code is as follows:
Very simple three blocks. Not even CSS styles are one by one.
Gets the current time and initializes the time format:
var Showtime;
Initialization time
function Inittime () {
var date=new date ();
var gyear=date.getfullyear ();
This gets the month time to manually add 1, because in the date () built-in function, the month default 0月-November
var
code. These codes collect and record the call relationship and number of calls of the function when the program is running, record the execution time of the function and the execution time of the called function.2) execute the compiled executable program, such as./test.exe. The running time of the program in this step is slightly slower than the running time of the normally compiled executable program. After the program is running, a file named gmon.
the called function.2) execute the compiled executable program, such as./test.exe. The running time of the program in this step is slightly slower than the running time of the normally compiled executable program. After the program is running, a file named gmon. Out is generated in the path where the program is located. This file is a data file that records the program running performance, call relationship, number of calls, and other information.3)
essence of the code, but just changes the appearance of the Code to make it more readable. This is always a good thing.GprofGprof is a program installed in the/usr/bin directory of your Linux system. It allows you to parse your program to know which part of the program is most time-consuming during execution.Gprof will tell you the number of calls to each function in the program and the percentage of time each function is executed. This information is useful if you want to improve the performan
. this will make the program generate a gmon every execution. out file. gprof uses this file to generate profiling information.After you run your program and generate the gmon. out file, you can use the following command to obtain the profiling information:Gprof
The program_name parameter is the name of the program that generates the gm
[size-1-I] = string;
String2 [size] = '';
Printf ("The string printed backward is % s", string2 );
}
Indent does not change the essence of the code, but just changes the appearance of the Code to make it more readable. This is always a good thing.
Gprof
Gprof is a program installed in the/usr/bin directory of your Linux system. It allows you to parse your program to know which part of the program is most time-consuming during execution.
installed in the/usr/bin directory of your Linux system. It allows you to parse your program to know which part of the program is most time-consuming during execution.
GPROF will tell you the number of calls to each function in the program and the percentage of time each function is executed. This information is useful if you want to improve the performance of your program.
To use GPROF in your program, you must add the-PG option when compiling the program. this will make the program generate a
);My_print2 (char * string){Char * string2;
Int size, size2, I;Size = strlen (string );
Size2 = size-1;
String2 = (char *) malloc (size + 1 );
For (I = 0; I
String2 [size2-I] = string [I];
String2 [size] = '/0;
Printf ("The string printed backward is % s/n", string2 );
}Indent does not change the actual content of the code, but just changes the appearance of the Code. It is always a good thing to make it more readable.GprofGprof is a program installed in the/usr/bin directory of your Linux sys
parameter during GCC Compilation:
Gcc-G-PG test. C-o Test
Run./test. After running the program, we can see that there are multiple gmon. out files in the directory. This is the GPROF log, which records the CPU usage information of the program running. Open to see? Cup, binary file, we humans don't understand... Run the following command to generate a report:
GPROF./test> report.txt
Open report.txt and we can see two tables.
First:
Fl
executed. This information is useful if you want to improve the performance of your program.To use gprof in your program, you must add the-pg option when compiling the program. This will make the program generate a file named gmon. out during each execution. Gprof uses this file to generate profiling information.After you run your program and generate the gmon. out file, you can use the following command t
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.